package com.actionpals.components.containers
{
	import com.actionpals.enum.Direction;
	import com.actionpals.utils.PositionUtil;
	
	
	public class Box extends Container
	{
		//--------------------------------------------------------------------------
		//
		//  Constructor
		//
		//--------------------------------------------------------------------------
		
		/**
		 * Constructor.
		 */	
		public function Box( direction:String = Direction.BELOW, margin:int = 5 )
		{
			super( margin );
			_direction = direction;
		}
		
		//--------------------------------------------------------------------------
		//
		//  Properties
		//
		//--------------------------------------------------------------------------
		
		//----------------------------------
		//  direction
		//----------------------------------
		
		/**
		 * @private
		 * Storage for the direction property.
		 */
		private var _direction:String;
		
		/**
		 * The direction determines how the container arranges the
		 * elements. The default is vertical. You can specify either
		 * horizontal or vertical as a string.
		 */
		public function get direction():String
		{
			return _direction;
		}
		
		/**
		 * @private
		 */
		public function set direction( value:String ):void
		{
			_direction = value;
			if( _autoArrange ) arrange();
		}
		
		//--------------------------------------------------------------------------
		//
		//  Overridden methods: Container
		//
		//--------------------------------------------------------------------------
		
		public override function arrange( index:int = 0 ):void
		{
			PositionUtil.stackChildren( this, _direction, _margin, index );
		}
		
	}
}